package com.yunc.modules.gen.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunc.modules.gen.entity.dto.ColumnDTO;
import com.yunc.modules.gen.entity.dto.TableDTO;
import com.yunc.modules.gen.mapper.GenMapper;
import com.yunc.modules.gen.service.IGenService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 数据库表操作service实现
 *
 * @author congcong tao
 * @date 2019/1/28 13:39
 */
@Service("genService")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class GenServiceImpl implements IGenService {

    private final GenMapper genMapper;

    @Override
    public Page pageInfo(Page<TableDTO> page, TableDTO tableDTO) {
        List<TableDTO> tableList = genMapper.selectEntityList(page, tableDTO);
        return page.setRecords(tableList);
    }

    @Override
    public List<ColumnDTO> getTableColumnsByName(String tableName) {
        return genMapper.getTableColumnsByName(tableName);
    }

    @Override
    public TableDTO getByTableName(String tableName) {
        return genMapper.getByTableName(tableName);
    }
}
